package com.taoyige.bean;

import java.io.InputStream;
import java.util.Date;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.taoyige.common.JacksonJsonUtil;

/**
 * 订单实体类
 * @author peter
 * @version 1.0
 * @created 2014-11-13
 */

@JsonIgnoreProperties(ignoreUnknown=true)
public class Order extends Entity{
	
	public final static String ORDER_ID = "id";
	public final static String ORDER_USER_ID = "userID";
	public final static String ORDER_GOODS_ID = "productID";
	public final static String ORDER_COUNT = "count";
	public final static String ORDER_AMOUNT = "amount";
	public final static String ORDER_TOTAL_PRICE = "totalPrice";
	public final static String ORDER_ORIGIN_PRICE = "oriPrice";
	public final static String ORDER_ADDR_INFO = "addressInfo";
	public final static String ORDER_TIMER = "timer";
	public final static String ORDER_EXPRESS_COMPANY = "expressCompany";
	public final static String ORDER_EXPRESS_NO = "expressNumber";
	public final static String ORDER_CUSTOM_EXPRESS_INFO = "customeExpressInfo";
	public final static String ORDER_FREIGHT = "freight";
	public final static String ORDER_PAYMENT_PLATFORM = "paymentPlatform";
	public final static String ORDER_PAYMENT_NOTICE = "paymentNotice";
	public final static String ORDER_OPERATION = "operation";
	public final static String ORDER_STATUS = "status";
	public final static String ORDER_TIMESTAMP = "timestamp";
	

	private String  userID;
	private Long productID;
	private Integer count;
	private Double amount;
	private Double totalPrice;
	private Double oriPrice;
	private Long timer;
	private String expressCompany;
	private Long expressNumber;
	private Double freight;
	private Integer paymentPlatform;
	private String paymentNotice;
	private String operation;
	private Date timestamp; 
	
	private Address addressInfo;
	
	private CustomExpressInfo customExpressInfo;
	private Goods product;
	
	
	private Integer status;
	
	public enum OrderStatus{
		UNPAID(1),PAID(2),DELIVERED(3),CHECKED(4),CLOSED(5),DELETED(6),REFUND(7),REFUND_SUCCESS(8),RETURN_GOODS(9),RETURN_GOODS_SUCCESS(10);
		private int code;
		private OrderStatus(int code){
			this.code=code;
		}
		public String toString(){
			return String.valueOf(this.code);
		}
	}
	
	
	public CustomExpressInfo getCustomExpressInfo() {
		return customExpressInfo;
	}

	public void setCustomExpressInfo(CustomExpressInfo customExpressInfo) {
		this.customExpressInfo = customExpressInfo;
	}

	public String getUserID() {
		return userID;
	}

	public void setUserID(String userID) {
		this.userID = userID;
	}

	public Long getProductID() {
		return productID;
	}

	public void setProductID(Long productID) {
		this.productID = productID;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		this.totalPrice = totalPrice;
	}

	
	public Address getAddressInfo() {
		return addressInfo;
	}

	public void setAddressInfo(Address addressInfo) {
		this.addressInfo = addressInfo;
	}

	public Goods getProduct() {
		return product;
	}

	public void setProduct(Goods product) {
		this.product = product;
	}

	public Long getTimer() {
		return timer;
	}

	public void setTimer(Long timer) {
		this.timer = timer;
	}

	public String getExpressCompany() {
		return expressCompany;
	}

	public void setExpressCompany(String expressCompany) {
		this.expressCompany = expressCompany;
	}

	public Long getExpressNumber() {
		return expressNumber;
	}

	public void setExpressNumber(Long expressNumber) {
		this.expressNumber = expressNumber;
	}


	public Double getFreight() {
		return freight;
	}

	public void setFreight(Double freight) {
		this.freight = freight;
	}

	public Integer getPaymentPlatform() {
		return paymentPlatform;
	}

	public void setPaymentPlatform(Integer paymentPlatform) {
		this.paymentPlatform = paymentPlatform;
	}

	public String getPaymentNotice() {
		return paymentNotice;
	}

	public void setPaymentNotice(String paymentNotice) {
		this.paymentNotice = paymentNotice;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public static Order  parse(InputStream ins) throws Exception {
		Order order = (Order) JacksonJsonUtil.jsonToBean(ins, Order.class);
		return order;
	}
	
	
	
	public Double getOriPrice() {
		return oriPrice;
	}

	public void setOriPrice(Double oriPrice) {
		this.oriPrice = oriPrice;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}
	
}
